/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.Collection;
import java.util.Hashtable;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import models.ProductType;
import models.Products;
import services.Impl.ProductsServiceImpl;
import services.interfaces.IProductService;

/**
 *
 * @author amega
 */
@ManagedBean(name="productsBean")
@SessionScoped
public class ProductsBean implements Serializable {

    /** Creates a new instance of ProductsBean */
    public ProductsBean() {
       pr.put("MEAT", ProductType.MEAT);
       pr.put("SOUP", ProductType.SOUP);
       pr.put("DRINKS", ProductType.DRINKS);
       pr.put("PIZZA", ProductType.PIZZA);
       pr.put("SALAT", ProductType.SALAT);
    }
    
    @EJB
    private ProductsServiceImpl productService;
    private Hashtable<String,ProductType> pr = new Hashtable<String, ProductType>();
    private Collection<Products> products ;
    private String type;
    private Products currentProducts = new Products();
    
    public Collection<Products> getAllProducts() {
        this.products = productService.findAll();
        return this.products;
    }

    public Collection<Products> getProducts() {
        return products;
    }

    public void setProducts(Collection<Products> products) {
        this.products = products;
    }
    
    
    public String addProducts() {
        //currentProducts.setPrType(ProductType.SOUP);
        productService.create(currentProducts);
        return "";
    }
    
    public void getProductsDrinks() {
        this.products = productService.getProductByType(ProductType.DRINKS);
    } 
    public void getProductsSalat() {
        this.products = productService.getProductByType(ProductType.SALAT);
    } 
    public void getProductsMeat() {
        this.products = productService.getProductByType(ProductType.MEAT);
    }
    public void getProductsPizza() {
        this.products = productService.getProductByType(ProductType.PIZZA);
    }
    public void getProductsSoup() {
        this.products = productService.getProductByType(ProductType.SOUP);
    }

    public Products getCurrentProducts() {
        return currentProducts;
    }

    public void setCurrentProducts(Products currentProducts) {
        this.currentProducts = currentProducts;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
    
    
}
